package com.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.entity.User;

@Component
//开启事务（需要配置）
@Transactional
public class UserDao {
	
	@Autowired
	private HibernateTemplate hibernateTemplate;
	
	public void add() {
		User user = new User();
		user.setUsername("xixi");
		user.setPassword("666");
		
		hibernateTemplate.save(user);
		System.out.println("userDao add 执行");
	}
}
